SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].gspPurchase_SEARCH
(
@purchaseId int = null,
@orderId int = null,
@productId int = null,
@quantity int = null,
@createdDate datetime = null,
@lastModifiedDate datetime = null,
@isDeleted bit = null
)
AS

SELECT
  *
FROM
  [dbo].[Purchase]
WHERE
  (@purchaseId IS NULL OR [PurchaseId] = @purchaseId)
AND
  (@orderId IS NULL OR [OrderId] = @orderId)
AND
  (@productId IS NULL OR [ProductId] = @productId)
AND
  (@quantity IS NULL OR [Quantity] = @quantity)
AND
  (@createdDate IS NULL OR [CreatedDate] = @createdDate)
AND
  (@lastModifiedDate IS NULL OR [LastModifiedDate] = @lastModifiedDate)
AND
  (@isDeleted IS NULL OR [IsDeleted] = @isDeleted)


GO
